package pl.szpadel.android.gadu.packets;

import java.nio.BufferOverflowException;
import java.nio.ByteBuffer;
import java.util.Collection;

import pl.szpadel.android.gadu.ContactInfo;

public class Notify extends SendPacket {

	private Collection<ContactInfo> mContacts;
	
	/// Creates a notify packet containing contact notofications.
	/// Clioent can sent any number of packets of this type in series, but the last one should be marked as last
	public Notify(Collection<ContactInfo> contacts, Boolean last) {
		super(last ? TYPE_NOTIFY_LAST : TYPE_NOTIFY_FIRST);
		assert(contacts.size() <= 400);
		mContacts = contacts;
	}

	@Override
	protected void writeToBuffer(ByteBuffer buffer)
			throws BufferOverflowException {
			
			for(ContactInfo contact : mContacts) {
				buffer.putInt((int)contact.id);
				buffer.put((byte)0x01); // any user, not a friend, not a blocked one
			}
		
	}

}
